package com.sirap.spring.boot.demo.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sirap.spring.boot.demo.helper.SirapHelper;

@Controller
@RequestMapping(value = "/sirap")
public class SirapController {

	@ResponseBody
	@GetMapping(value = "/calcRest")
	public Map<String, Object> calRest(HttpServletRequest request) {
		Map<String, Object> result = SirapHelper.calculate(request);
		
		return result;
	}
	
	@GetMapping(value = "/calc")
	public String calculate(HttpServletRequest request, Map<String, Object> map) {
		Map<String, Object> result = SirapHelper.calculate(request);
		if(result != null) {
			map.putAll(result);
		}
		
		return "sirapResult";
	}
}
